﻿using System;
using System.Data;
using visinia.SmartEngine.Providers;

namespace viPage.Providers
{
    public abstract partial class viPageDataProvider
    {
        #region INIT
        private static viPageDataProvider _provider;
        private static object _lock = new object();

        public static viPageDataProvider Provider
        {
            get { InternalInitialize(); return _provider; }
        }
        private static void InternalInitialize()
        {
            if (_provider == null)
            {
                lock (_lock)
                {
                    if (_provider == null)
                    {
                        _provider = (viPageDataProvider)ProviderController.CreateDataProvider("viPage");
                        if (_provider == null)
                            throw new Exception("Unable to load default viPageDataProvider");
                    }
                }
            }
        }
        #endregion

        #region WikiPages
        public abstract IDataReader GetPages();
        public abstract IDataReader AddPage(int WebPageId, string Name, string Title);
        public abstract void UpdatePage(int PageId, int WebPageId, string Name, string Title);
        public abstract void DeletePage(int WikiPageId);
        #endregion

        public abstract IDataReader GetBaseSettings();
        public abstract void AddBaseSetting(string key, string value);
        public abstract void UpdateBaseSetting(string key, string value);
        public abstract void DeleteBaseSetting(string key);        
    }
}
